package com.pos.widgets.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.pos.R;

/**
 * @Description:list dialog
 * @author:Cai
 * @time:2016-12-23 上午11:32:56
 */
public class ListDialog {
	private Context mContext;
	private Dialog dialog;
	private View view;
	private LayoutInflater inflater;
	private ListView mListView;

	public ListDialog(Context context) {
		mContext = context;
		dialog = new Dialog(context, R.style.dialog);
		inflater = LayoutInflater.from(context);
		view = inflater.inflate(R.layout.list_dialog_layout, null);
		mListView = (ListView) view.findViewById(R.id.listview);
		dialog.setContentView(view);
	}

	public void showDialog(String[] listData, OnItemClickListener listener) {
		mListView.setAdapter(new ArrayAdapter<String>(mContext, R.layout.dialog_list_item_layout, listData));
		mListView.setOnItemClickListener(listener);
		dialog.show();
	}

	public void dismissDialog() {
		dialog.dismiss();
	}

}
